import  numpy  as  np
import  cv2
import matplotlib.pyplot as plt

img = cv2.imread('photo/MAIKAILUN.jpg',1)
img1 = cv2.imread('photo/MAIKAILUN.jpg',0)
img2 = cv2.imread('photo/MAIKAILUN.jpg',-1)
img3 = np.zeros((512,512,3),np.uint8)
img4 = cv2.imread('photo/3D-Matplotlib.png',0)
img5 = cv2.imread('photo/mainsvmimage.png',0)
img6 = cv2.imread('photo/mainLogo.png')
#展示   通过cv2展示
# cv2.imshow('img',img1)
# cv2.waitKey(0)
# cv2.imwrite('wwwwww.png',img) #保存图片
# cv2.destroyAllWindows()


#通过matplotlib展示
# image = [img,img1,img2]
# plt.imshow(img1,cmap='gray',interpolation='bicubic')
# plt.show()



#图片操作 应用场景不明
px = img[100,100]  #获取像素点 先高后宽
#
# roi = img[300:700,600:800]    #获取该区域所有像素
# img[200:600,500:700] = [255,255,255]  #对指定区域进行更改颜色
#
# img3[0:400,0:200] = roi    #将roi粘贴到目标图片目标区域    大小要一致，否则会报错
# cv2.imshow('img',img3)
# cv2.waitKey(0)
# cv2.destroyAllWindows()


#图片逻辑运算
# img62gray = cv2.cvtColor(img6,cv2.COLOR_BGR2GRAY)
# ret,mask = cv2.threshold(img62gray,220,255,cv2.THRESH_BINARY_INV)
#
# mask_int = cv2.bitwise_and(img6,img6,mask=mask)
#
# # img6_bg =cv2.bitwise_or(mask)
#
# cv2.imshow('img',img6)
# cv2.waitKey(0)
# cv2.destroyAllWindows()


#阈值
# img_book = cv2.imread('photo/bookpage.jpg')
# retval,threshold = cv2.threshold(img_book,12,255,cv2.THRESH_BINARY)
#
# gray_book = cv2.cvtColor(img_book,cv2.COLOR_BGR2GRAY)
# threshold_gus = cv2.adaptiveThreshold(gray_book,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,115,1)  #高斯滤波算法
# retval_otsu,threshold_otsu = cv2.threshold(gray_book,5,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)   #大津优化
#
# # cv2.imshow('img',img_book)
# # cv2.imshow('threshold',threshold)
# cv2.imshow('threshold_gus',threshold_gus)
# cv2.imshow('threshold_otsu',threshold_otsu)
#
#
# cv2.waitKey(0)
# cv2.destroyAllWindows()